﻿
@{
    ViewBag.Title = "ChoosePrescription";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<script>
    $(function () {
        gridList();
    });

    ///获取处方列表
    function GetPrescriptionInfo() {
        var PrescriptionInfo = sessionStorage.getItem("PrescriptionInfo");
        if (PrescriptionInfo) {
            sessionStorage.removeItem("PrescriptionInfo")
            return $.parseJSON(PrescriptionInfo);
        }

    }

    function gridList() {
        var $gridList = $("#parentgridList");
        $gridList.newtouchLocalDataGrid({
            multiselect: true,
            unwritten: false,
            height: 150,
            colModel: [
                { label: "cfnm", name: "cfnm", key: true, hidden: true },
                { label: "处方号", name: "cfh", width: 200, align: 'left' },
                { label: '总金额', name: 'zje', width: 50, align: 'left' },
                { label: '处方类型', name: 'cflx', width:80, align: 'left' },
                { label: '科室名称', name: 'ksmc', width: 50, align: 'left' },
                { label: '医生名称', name: 'ysmc', width: 50, align: 'left' }
            ]
        });
        $gridList.newtouchLocalDataGrid(null, GetPrescriptionInfo());
    }


    function submitForm(callback) {
        //获取选中行Id
        var selRowIds = $("#parentgridList").jqGrid('getGridParam', 'selarrrow');
        if (selRowIds.length == 0) {
            $.modalAlert("请先选中处方", 'warning');
            return;
        }
        //cfnm
        var cfnmList = [];//查询处方详情的处方内码list
        for (var i = 0; i < selRowIds.length; i++) {
            var rowData = $("#parentgridList").jqGrid('getRowData', selRowIds[i]);
            if (!rowData) {
                break;
            }
            cfnmList.push(parseInt(rowData.cfnm));
        }
        $.ajax({
            type: "POST",
            url: "/OutpatientManage/OutpatCharge/loadPrescriptionDetailDataBycfnm",
            data: { cfnmList: cfnmList },
            dataType: "json",
            cache: false,
            async: true,
            success: function (ajaxresp) {
                callback(ajaxresp, cfnmList);
                $.modalClose();
            },
            complete: function () {
                $.loading(false);
            }
        });
    }
</script>
<div class="gridPanel">
    <table id="parentgridList"></table>
</div>